package com.codeduck.properties.byAnnotation;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

/**
 * @author: <a href="mailto:codeduck@163.com">Codeduck</a>
 * @date: 2025/4/23
 */
@Configuration
@PropertySource(value = {"classpath:META-INF/kafka-producer.properties"})
public class ProducerProperties {

    @Value("${kafka.bootstrap.servers}")
    private String bootstrapServers;

    @Bean("kafkaConfigProperties")
    public Map<String, Properties> producerProperties() {
        Properties properties = new Properties();
        properties.put("bootstrap.servers", bootstrapServers);
        properties.put("acks", "all");
        properties.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
        properties.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
        properties.put("batch.size", 16384);
        properties.put("linger.ms", 5000);
        properties.put("compression.type", "lz4");
        Map<String, Properties> ret =new HashMap<String, Properties>();
        ret.put("test", properties);
        return ret;
    }
}
